import request from '@/utils/request'

// 查询采购合同(es_procurement_contract)列表
export function listContract(query) {
  return request({
    url: '/procurementmanagement/contract/list',
    method: 'get',
    params: query
  })
}

// 查询采购合同(es_procurement_contract)详细
export function getContract(id) {
  return request({
    url: '/procurementmanagement/contract/' + id,
    method: 'get'
  })
}


// 新增采购合同(es_procurement_contract)
export function addContract(data) {
  return request({
    url: '/procurementmanagement/contract',
    method: 'post',
    data: data
  })
}

// 修改采购合同(es_procurement_contract)
export function updateContract(data) {
  return request({
    url: '/procurementmanagement/contract',
    method: 'put',
    data: data
  })
}

// 删除采购合同(es_procurement_contract)
export function delContract(id) {
  return request({
    url: '/procurementmanagement/contract/' + id,
    method: 'delete'
  })
}

// 更新合同状态
export function updateContractStatus(id, status) {
  return request({
    url: `/procurementmanagement/contract/${id}/status`,
    method: 'put',
    data: { status }
  });
}

// 获取采购合同产品列表
export function getContractProducts(id) {
  return request({
    url: `/procurementmanagement/contract/${id}/products`,
    method: 'get'
  })
}
